import request from '@neu/biz-core/utils/request'
const baseUrl = 'dcom/api/w/insurance/register/task'

// 重保服务登记任务
export const list = (params) => {
  return request({
    url: baseUrl,
    params,
    method: 'get'
  })
}

export const page = (params) => {
  return request({
    url: baseUrl + '/p',
    params,
    method: 'get'
  })
}

export const detail = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'get'
  })
}

export const update = (id, data) => {
  return request({
    url: baseUrl + '/' + id,
    data,
    method: 'put'
  })
}

// 重保服务巡检任务
export const inspectionList = (params) => {
  return request({
    url: baseUrl + '/inspection',
    params,
    method: 'get'
  })
}

export const inspectionUpdate = (id, data) => {
  return request({
    url: baseUrl + '/inspection' + '/' + id,
    data,
    method: 'put'
  })
}

export const inspectionSubmit = (id, data) => {
  return request({
    url: baseUrl + '/inspection' + '/submit/' + id,
    data,
    method: 'put'
  })
}

export const inspectionDetail = (registerTaskId, type) => {
  return request({
    url: baseUrl + '/inspection' + '/' + registerTaskId + '/' + type,
    method: 'get'
  })
}

// 每日上报任务
export const reportList = (params) => {
  return request({
    url: baseUrl + '/report',
    params,
    method: 'get'
  })
}

export const reportUpdate = (id, data) => {
  return request({
    url: baseUrl + '/report' + '/' + id,
    data,
    method: 'put'
  })
}

export const reportDetail = (id) => {
  return request({
    url: baseUrl + '/report' + '/' + id,
    method: 'get'
  })
}

// 服务总结任务
export const summaryList = (params) => {
  return request({
    url: baseUrl + '/summary',
    params,
    method: 'get'
  })
}

export const summaryUpdate = (id, data) => {
  return request({
    url: baseUrl + '/summary' + '/' + id,
    data,
    method: 'put'
  })
}

export const summaryDetail = (id) => {
  return request({
    url: baseUrl + '/summary' + '/' + id,
    method: 'get'
  })
}

export const summaryUpload = baseUrl + '/summary/upload'

export const summaryDownload = (fsId) => {
  return request({
    url: baseUrl + '/summary/download/' + fsId,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}

export const deletefiles = (fsId) => {
  return request({
    url: baseUrl + '/summary/files/' + fsId,
    method: 'delete'
  })
}

export const report = (params) => {
  return request({
    url: baseUrl + '/stats/report',
    params,
    method: 'get'
  })
}

export const exportReport = (params) => {
  return request({
    url: baseUrl + '/stats/export',
    params,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}
